diff --git a/django/db/backends/base/schema.py b/django/db/backends/base/schema.py
index be33ab3e4d..0fcad22ca6 100644
--- a/django/db/backends/base/schema.py
+++ b/django/db/backends/base/schema.py
@@ -113,8 +113,13 @@ class BaseDatabaseSchemaEditor:
 
     def __exit__(self, exc_type, exc_value, traceback):
         if exc_type is None:
-            for sql in self.deferred_sql:
-                self.execute(sql)
+            try:
+                for sql in self.deferred_sql:
+                    self.execute(sql)
+            except Exception as e:
+                # Handle the exception, possibly by logging and re-raising
+                logger.error("Failed to execute deferred SQL: %s", e)
+                raise
         if self.atomic_migration:
             self.atomic.__exit__(exc_type, exc_value, traceback)
 
